import { ReactivePropsToNativePropsAndChanged, SceneObjectKey, extendClassProps, reactPositions } from "earthsdk3";
import { ESGeoExtrudedPolygonUFMS } from "../ESGeoExtrudedPolygonUFMS";
import { ElMessage } from 'element-plus';

/**
 * 测试 ModelSer使用的挤压多边形体
 */
export class ESGeoExtrudedPolygonUFMSFromLineString extends ESGeoExtrudedPolygonUFMS {
    static override readonly type: string = this.register('ESGeoExtrudedPolygonUFMSFromLineString', this, { chsName: 'ModelSer使用的地理多边形体', tags: ['ESObjects', '_ES_Impl_Cesium', '_ES_Impl_UE'], description: "地理多边形体" });

    static override defaults = {
        ...ESGeoExtrudedPolygonUFMS.defaults,
        width: 5,
    }

    constructor(id?: SceneObjectKey) {
        super(id);
        this.collision = false;
        {
            let message: any
            const updata = () => {
                if (this.positionEditing) {
                    message = ElMessage({
                        message: '1. 双击鼠标左键或点击ESC键退出编辑2. 点击空格键进行编辑方式的切换',
                        duration: 0,
                        plain: true,
                    })
                } else {
                    message && message.close()
                }
            }
            this.dispose(this.positionEditingChanged.disposableOn(updata))
            this.dispose(() => message && message.close())

        }
    }
}

export namespace ESGeoExtrudedPolygonUFMSFromLineString {
    export const createDefaultProps = () => ({
        ...ESGeoExtrudedPolygonUFMS.createDefaultProps(),
        width: undefined as number | undefined,
        positionEditing: false,
        linePoints: reactPositions(undefined)
    });
}
extendClassProps(ESGeoExtrudedPolygonUFMSFromLineString.prototype, ESGeoExtrudedPolygonUFMSFromLineString.createDefaultProps);
export interface ESGeoExtrudedPolygonUFMSFromLineString extends ReactivePropsToNativePropsAndChanged<ReturnType<typeof ESGeoExtrudedPolygonUFMSFromLineString.createDefaultProps>> { }